Skip to content

[Fix] Add non-destructive recovery for VirtualDisplay map freezes when returning from the Android background#61

Open
gunyu1019 wants to merge 4 commits into
developfrom
bugfix/android-engine-recovery
Open

[Fix] Add non-destructive recovery for VirtualDisplay map freezes when returning from the Android background#61
gunyu1019 wants to merge 4 commits into
developfrom
bugfix/android-engine-recovery

Conversation

@gunyu1019

Copy link
Copy Markdown
Owner

Change Log

Root cause identified:

  • Flutter engine's VirtualDisplayController.resetSurface() fully recreates the VirtualDisplay and SingleViewPresentation on every Activity resume, detaching/reattaching the PlatformView. This is an Android 14-only HardwareRenderer workaround (Workaround HardwareRenderer breakage in Android 14 flutter-team-archive/engine#52370) that runs on all API levels without a version gate.
  • Kakao SDK's forked GLSurfaceView (com.kakao.vectormap.graphics.gl.GLSurfaceView) pauses its GL thread on a non-finishing detach but never resumes it on reattach, and MapView.resume() only resumes the native renderer — it never wakes the GL thread — leaving the map permanently frozen.

Changes:

  • Added recoverAndroidGLSurfaceViewOnResume option (default true): non-destructive recovery that detects the engine rehost and calls the fork's GLSurfaceView.onResume() followed by MapView.resume(). No onMapReady re-fire; all registered overlays are preserved.
  • Changed recreateAndroidMapViewOnResume default from true to false: destructive MapView recreation is demoted to an emergency fallback.

Issue Number

Checklist

  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)

@gunyu1019
gunyu1019 requested a review from Copilot July 12, 2026 18:04
@gunyu1019 gunyu1019 self-assigned this Jul 12, 2026
@gunyu1019 gunyu1019 added the bug Something isn't working label Jul 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an Android-specific, non-destructive recovery path for Kakao Map freezes caused by Flutter’s VirtualDisplay rehost behavior on Activity resume, while keeping a destructive MapView recreation path as an opt-in fallback.

Changes:

  • Adds recoverAndroidGLSurfaceViewOnResume (default true) and wires it through Flutter → Android to recover Kakao’s forked GLSurfaceView thread on reattach.
  • Demotes MapView recreation to an opt-in fallback (recreateAndroidMapViewOnResume, default false) and preserves camera position across recreation.
  • Updates controller/overlay state to reset cleanly after native MapView recreation; updates widget tests accordingly.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/kakao_map_widget_test.dart Adjusts Android params assertions (strips injected recovery flag) and adds coverage for recreation params.
lib/widget/map_widget.dart Introduces new Android resume recovery/recreate options and injects them into platform creation params; resets controller state on repeated native onMapReady.
lib/controller/overlay/overlay_manager.dart Allows overlay controllers to be re-initialized after native recreation (removes final).
lib/controller/controller_implement.dart Adds controller reset routine to clear/reinitialize overlay state after native MapView recreation.
android/src/main/kotlin/kr/yhs/flutter_kakao_maps/views/KakaoMapViewFactory.kt Plumbs new resume recovery/recreate options from creation params into KakaoMapView.
android/src/main/kotlin/kr/yhs/flutter_kakao_maps/views/KakaoMapView.kt Implements container-based MapView hosting, delayed recreation, camera preservation, and GLSurfaceView recovery on reattach.
android/src/main/kotlin/kr/yhs/flutter_kakao_maps/model/KakaoMapOption.kt Adds helper to recreate options while preserving camera position.
.gitignore Ignores local Android engine debugging artifacts and normalizes .swiftpm/ entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +60 to +67
val pendingRecreate = recreateMapViewOnResume && wasActivityPaused
val recoveryActive = recoverGLSurfaceViewOnResume && !recreateMapViewOnResume && wasActivityPaused
isActivityResumed = true
if (pendingRecreate) {
wasActivityPaused = false
scheduleMapViewRecreation()
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants